package chapter6;

/**
 * 直接排序法
 */
public class SelectSort {
    public static void main(String[] args) {
        int[] arr = {4,1,3,6,9,7};
        int index;
        for (int i = 1; i < arr.length ; i++) {
            index = 0;
            for (int j = 1; j < arr.length-i; j++) {
                if(arr[j] > arr[index]){
                    index = j;
                }
            }
            int temp = arr[arr.length-i];
            arr[arr.length-i] = arr[index];
            arr[index] = temp;
        }
        for(int i = 0; i <arr.length; i++){
            System.out.println(arr[i]);
        }
    }
}
